<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>坐标拾取与鹰眼控件</title>
    <link rel="stylesheet" href="../v6.4.3/css/ol.css">
    <link rel="stylesheet" href="css/zoom.css">
  </head>

  <body>
    <!-- 核心地图容器 -->
    <div id="map" style="height: 500px;"></div>

    <script src="../v6.4.3/build/ol.js"></script>
    <script>
      const map = new ol.Map({
        target: 'map',
        layers: [
          new ol.layer.Tile({
            source: new ol.source.OSM()
          })
        ],
        view: new ol.View({
          projection: 'EPSG:3857',
          center: [0, 0],
          zoom: 0
        }),
        // 新增代码，加上各种控件（Zoom控件是默认带上的）
        controls: ol.control.defaults().extend([
          new ol.control.MousePosition(), //坐标拾取控件
          new ol.control.OverviewMap({ //鹰眼控件
            collapsed: false
          }),
          new ol.control.ScaleLine({
            // units: 'degre' 
            // 比例尺控件 可以修改 ScaleLine类的units属性，
            // 接受的值有 "degrees"、"imperial"、"us"、"nautical"，默认为 "metric"
          }) 
        ])
      })
    </script>
  </body>
</html>